let constData = {}

constData.pickerOptions = {
  shortcuts: [{
    text: '最近一周',
    onClick (picker) {
      // const end = new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1)
      const end = new Date()
      // const start = new Date(new Date(new Date().toLocaleDateString()).getTime())
      const start = new Date()
      start.setHours(0, 0, 0, 0)
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近一个月',
    onClick (picker) {
      const end = new Date()
      const start = new Date()
      start.setHours(0, 0, 0, 0)
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近三个月',
    onClick (picker) {
      const end = new Date()
      const start = new Date()
      start.setHours(0, 0, 0, 0)
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      picker.$emit('pick', [start, end])
    }
  }]
}

constData.validateMoney = (rule, value, callback) => {
  let tmp = value + ''
  let dotIndex = tmp.indexOf('.')
  if (dotIndex === -1) {
    callback()
  } else {
    tmp = tmp.substr(dotIndex + 1)
    if (tmp.length === 2 || tmp.length === 1) {
      callback()
    } else {
      callback(new Error('小数点后保留两位'))
    }
  }
}

export default constData
